﻿//-----------------------------------------------------------------------
// <copyright file="BusinessRule.cs" company="FastNET Services">
//     Copyright (c) 2007-2013. All Rights Reserved.
// </copyright>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings



#endregion

namespace FastNet.BusinessSystem.Rules
{
    /// <summary>
    /// Base class used for managing business rules for an object
    /// </summary>
    public abstract class BusinessRule
    {
        #region CTor/DTor

        /// <summary>
        /// Initializes a new instance of the BusinessRule class
        /// </summary>
        /// <param name="ruleName">Name of the rule</param>
        /// <param name="propertyName">Name of the property the rule validates</param>
        /// <param name="errorMessage">Message to display when in error</param>
        protected BusinessRule(string ruleName, string propertyName, string errorMessage)
        {
            RuleName = ruleName;
            PropertyName = propertyName;
            ErrorMessage = errorMessage;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the name of the rule
        /// </summary>
        public string RuleName { get; private set; }

        /// <summary>
        /// Gets the name of the property the rule validates
        /// </summary>
        public string PropertyName { get; private set; }

        /// <summary>
        /// Gets the message to display when the rule is invalid
        /// </summary>
        public string ErrorMessage { get; private set; }

        #endregion

        #region Methods

        /// <summary>
        /// Called to check the validity of the rule
        /// </summary>
        /// <returns>Boolean whether or not the rule is valid</returns>
        public abstract bool IsValid();

        #endregion
    }
}
